package com;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class Updata extends TimerTask {
	    //时间量
	    Date startDate = new Date();
	    //定时器

	    private Timer timer = new Timer();
	    public void start(){
	        //2秒执行一次	  
	        timer.schedule(this, startDate, 86400000);
	        
	    }
	    public void run() {
	    	
	    	String TeaId="",TeaName="",DepName="计人",IsCheck="未完成",IsTested="未完成",IsUnUsual="无";
	    	//String Date= new Datetools().getTime();
	    	 String Date="";
			try {
				Date = new Datetools().getDateTime();
			} catch (ParseException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
	    	String sql="";
	        double round = Math.round(1);
	        System.out.println("round:"+round);
	        try {
	        
	        	ResultSet rs = new DBtools().query("select * from teacher");//尚未完善，更改	
	        	int r=0;
	            while(rs.next()) {
	            	TeaId=rs.getString("TeaId");
	            	TeaName=rs.getString("TeaName");
	            	sql = "insert into teastatistics values("+TeaId+",'"+Date+"','"+TeaName+"','"+DepName+"','"+IsCheck+"','"+IsTested+"','"+IsUnUsual+"')";
	            	 r = new DBtools().execute(sql);
	            }
	            rs.close(); 
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	    }
	}

	

